﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace Project.Home
{
    public partial class WebForm5 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }


        protected void Button2_Click(object sender, EventArgs e)
        {
            // DataPOFDataContext db = new DataPOFDataContext();
            DataPOFDataContext data = new DataPOFDataContext();

            if (TextBox1.Text != null && TextBox2.Text != null)
            {
                Session["username"] = TextBox1.Text;
                string user = (from x in data.AccountLogins where x.Username == TextBox1.Text select x.Roll).FirstOrDefault();
                string pass = (from x in data.AccountLogins where x.Username == TextBox1.Text select x.Password).FirstOrDefault();
                string teller = (from x in data.AccountLogins where x.Username == TextBox1.Text select x.Roll).FirstOrDefault();
                string passteller = (from x in data.AccountLogins where x.Username == TextBox1.Text select x.Password).FirstOrDefault();

                if (TextBox2.Text == pass & RadioButton1.Checked & user == "admin")
                {
                    Response.Redirect("../Admin/Admin.aspx");
                }

                if (TextBox2.Text == passteller & RadioButton2.Checked & teller == "teller")
                {
                    Response.Redirect("../Teller/Teller.aspx");
                }
                else
                {

                    Label1.Text = "Username or password is not Correct!";
                    Label1.ForeColor = System.Drawing.Color.Red;
                }
            }

            else
            {

                Label1.Text = "Username or password is not Correct!";

            }
        }

        protected void TextBox2_TextChanged(object sender, EventArgs e)
        {

        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            TextBox1.Text = null;
            TextBox2.Text = null;
            RadioButton1.Checked = false;
            RadioButton2.Checked = false;
        }

        protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton2.Checked = false;
        }

        protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton1.Checked = false;
        }
    }
}